package org.apache.dubbo.demo.example.filter;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcException;

@Activate(group = Constants.PROVIDER, value = "test")
public class InvokeFilter implements Filter {

  @Override
  public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    System.out.println("InvokeFilter invoked");
    return invoker.invoke(invocation);
  }

  @Override
  public Result onResponse(Result result, Invoker<?> invoker, Invocation invocation) {
    System.out.println("InvokeFilter result: " + result.getValue());
    return result;
  }
}
